package com.thread.thread.同步容器;

import java.util.concurrent.ArrayBlockingQueue;
//基于数组的并发阻塞队列,内部使用锁机制
//卖票
public class ArrayBlockingQueueTest {

	static ArrayBlockingQueue<String> list = new ArrayBlockingQueue<String>(10000);
	static{
		for (int i=0;i<10000;i++){
			list.add("票编号"+i);
		}
	}

	public static void main(String[] args) throws Exception {
			for(int i=0;i<10;i++){
				new  Thread(()->{

					while (list.size()>0){
						String s=list.poll();
						if(s==null) break;
						else{
							System.out.println("销售"+s);
						}

					}
				}).start();
			}

	}
}
